import request from '@/router/request_sys'
import { encrypt } from '@/util/rsaEncrypt'
import {baseUrl} from '@/config/env';
import qs from 'qs';
export function getUsers(params) {
  return request({
    url: 'api/users' + '?'+ qs.stringify(params, { indices: false }),
    method: 'get',
  })
}
export function add(data) {
  return request({
    url: 'api/users',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/users',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/users',
    method: 'put',
    data
  })
}

export function editUser(data) {
  return request({
    url: 'api/users/center',
    method: 'put',
    data
  })
}

export function updatePass(user) {
  const data = {
    oldPass: encrypt(user.oldPass),
    newPass: encrypt(user.newPass)
  }
  return request({
    url: 'api/users/updatePass/',
    method: 'post',
    data
  })
}

export function updateEmail(form) {
  const data = {
    password: encrypt(form.pass),
    email: form.email
  }
  return request({
    url: 'api/users/updateEmail/' + form.code,
    method: 'post',
    data
  })
}
//根据工号新增用户
export function queryUser(data) {
  return request({
    url: 'api/hrUser/queryUserByUserNo',
    method: 'get',
    params: data
  })
}

export default { getUsers, add, edit, del,queryUser }

